<template>
  <div>
    <TableStyel
      :THeader="THeader"
      :TData="TData"
      :pagination="pagination"
      @sizeChange="handleSizeChange"
      @currentChange="handleCurrentChange"
      @mouseEnter="handleMouseEnter"
      @mouseLeave="handleMouseLeave"
      @delete="handleDelete"
      @gotoName="handleGotoName"
      :numberChange="['input']"
    />
  </div>
</template>

<script>
import TableStyel from "@/components/TableStyel/TableStyel";
export default {
  name: "demonstration",
  data(){
    return {
      THeader:[
        {
          prop: 'serial',
          label: '序号',
        },
        {
          prop: 'name',
          label: '姓名',
          remarks: '这是姓名的备注',
          event: 'gotoName'
        },
        {
          prop: 'date',
          label: '日期'
        },
        {
          prop: 'address',
          label: '地址'
        },
        {
          prop: 'address',
          label: '地址'
        },
        {
          prop: 'input',
          label: '输入框'
        },
        {
          prop: 'operation',
          label: '操作'
        },
      ],
      TData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄',
          input: 1,
          operation: [
            {
              name: '编辑',
              event: 'edit'
            },
            {
              name: '删除',
              event: 'delete'
            }
          ]
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄',
          input: 1,
          operation: [
            {
              name: '删除',
              event: 'delete'
            }
          ]
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄',
          input: 1,
          operation: [
            {
              name: '删除',
              event: 'delete'
            }
          ]
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
          input: 1,
          operation: [
            {
              name: '删除',
              event: 'delete'
            }
          ]
        }
      ],
      pagination: {
        total: 0,
        pageSize: 20,
        currentPage: 1,
        layout: "total, prev, pager, next, sizes",
        popperClass: "green"
      }
    }
  },
  components:{
    TableStyel
  },
  methods:{
    handleSizeChange(size){
      console.log(`选择的页大小${size}`);
    },
    handleCurrentChange(page){
      console.log(`选择的页${page}`);
    },
    handleMouseEnter(row, column, cell, event){
      // console.log(`鼠标移入单元格`);
      console.log(row, column, cell, event);
    },
    handleMouseLeave(row, column, cell, event){
      // console.log(`鼠标移出单元格`);
      console.log(row, column, cell, event);
    },
    handleDelete(row,key){
      this.TData.splice(key, 1)
    },
    // 单元格内容可点击
    handleGotoName(row) {
      console.log(row);
    }
  }
}
</script>

<style scoped>

</style>
